package com.irdstudio.efp.nls.service.impl;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.nls.service.dao.WsApplyNotifyDao;
import com.irdstudio.efp.nls.service.domain.WsApplyNotify;
import com.irdstudio.efp.nls.service.facade.WsApplyNotifyService;
import com.irdstudio.efp.nls.service.vo.WsApplyNotifyVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;


/**
 * Service Impl: 网商授信初审信息表服务实现
 * @author ligm
 * @date 2019-08-08 
 */
@Service("wsApplyNotifyService")
public class WsApplyNotifyServiceImpl implements WsApplyNotifyService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(WsApplyNotifyServiceImpl.class);

	@Autowired
	private WsApplyNotifyDao wsApplyNotifyDao;

   	/**
	 * 新增数据 
     * @param inWsApplyNotifyVo
     * @return 
	 */
	public int insertWsApplyNotify(WsApplyNotifyVO inWsApplyNotifyVo) {
		logger.debug("当前新增数据为:"+ inWsApplyNotifyVo.toString());
		int num = 0;
		try {
			WsApplyNotify wsApplyNotify = new WsApplyNotify();
			beanCopy(inWsApplyNotifyVo, wsApplyNotify);
			num = wsApplyNotifyDao.insertWsApplyNotify(wsApplyNotify);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

    /**
	 * 根据主键删除信息 
	 * @param inWsApplyNotifyVo
 	 * @return
	 */
	public int deleteByPk(WsApplyNotifyVO inWsApplyNotifyVo) {
		logger.debug("当前删除数据条件为:"+ inWsApplyNotifyVo);
		int num = 0;
		try {
			WsApplyNotify wsApplyNotify = new WsApplyNotify();
			beanCopy(inWsApplyNotifyVo, wsApplyNotify);
			num = wsApplyNotifyDao.deleteByPk(wsApplyNotify);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inWsApplyNotifyVo +"删除的数据条数为"+ num);
		return num;
	}


    /**
	 * 根据主键更新信息 
	 * @param inWsApplyNotifyVo
	 * @return 
	 */  
	public int updateByPk(WsApplyNotifyVO inWsApplyNotifyVo) {
		logger.debug("当前修改数据为:"+ inWsApplyNotifyVo.toString());
		int num = 0;
		try {
			WsApplyNotify wsApplyNotify = new WsApplyNotify();
			beanCopy(inWsApplyNotifyVo, wsApplyNotify);
			num = wsApplyNotifyDao.updateByPk(wsApplyNotify);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ inWsApplyNotifyVo +"修改的数据条数为"+ num);
		return num;
	}
	
    /**
	 * 根据主键查询详情 
	 * @param wsApplyNotify
	 * @return 
	 */
	public WsApplyNotifyVO queryByPk(WsApplyNotifyVO inWsApplyNotifyVo) {
		
		logger.debug("当前查询参数信息为:"+ inWsApplyNotifyVo);
		try {
			WsApplyNotify queryWsApplyNotify = new WsApplyNotify();
			beanCopy(inWsApplyNotifyVo, queryWsApplyNotify);
			WsApplyNotify queryRslWsApplyNotify = wsApplyNotifyDao.queryByPk(queryWsApplyNotify);
			if (Objects.nonNull(queryRslWsApplyNotify)) {
				WsApplyNotifyVO outWsApplyNotifyVo = beanCopy(queryRslWsApplyNotify, new WsApplyNotifyVO());
				logger.debug("当前查询结果为:"+ outWsApplyNotifyVo.toString());
				return outWsApplyNotifyVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}


    /**
	 * 一级数据权限 
	 * @param wsApplyNotify
	 * @return 
	 */	
	@SuppressWarnings("unchecked")
	public List<WsApplyNotifyVO> queryAllByLevelOne(WsApplyNotifyVO wsApplyNotifyVo) {
		logger.debug("查看当前用户对应的数据信息的参数信息为:");
		List<WsApplyNotifyVO> list = null;
		try {
			List<WsApplyNotify> wsApplyNotifys = wsApplyNotifyDao.queryAllByLevelOneByPage(wsApplyNotifyVo);
			logger.debug("查看当前用户对应的数据信息的结果集数量为:"+ wsApplyNotifys.size());
			pageSet(wsApplyNotifys, wsApplyNotifyVo);
			list = (List<WsApplyNotifyVO>) beansCopy(wsApplyNotifys, WsApplyNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 二级数据权限 
	 * @param wsApplyNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApplyNotifyVO> queryAllByLevelTwo(WsApplyNotifyVO wsApplyNotifyVo) {
		logger.debug("查看当前用户及所属机构对应的数据信息的参数信息为:");
		List<WsApplyNotify> wsApplyNotifys = wsApplyNotifyDao.queryAllByLevelTwoByPage(wsApplyNotifyVo);
		logger.debug("查看当前用户及所属机构对应的数据信息的结果集数量为:"+wsApplyNotifys.size());
		List<WsApplyNotifyVO> list = null;
		try {
			pageSet(wsApplyNotifys, wsApplyNotifyVo);
			list = (List<WsApplyNotifyVO>) beansCopy(wsApplyNotifys, WsApplyNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	
	}


    /**
	 * 三级数据权限 
	 * @param wsApplyNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApplyNotifyVO> queryAllByLevelThree(WsApplyNotifyVO wsApplyNotifyVo) {
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的参数信息为:");
		List<WsApplyNotify> wsApplyNotifys = wsApplyNotifyDao.queryAllByLevelThreeByPage(wsApplyNotifyVo);
		logger.debug("查看当前用户所在机构及下属机构对应的数据信息的结果集数量为:"+ wsApplyNotifys.size());
		List<WsApplyNotifyVO> list = null;
		try {
			pageSet(wsApplyNotifys, wsApplyNotifyVo);
			list = (List<WsApplyNotifyVO>) beansCopy(wsApplyNotifys, WsApplyNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 四级数据权限  
	 * @param wsApplyNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApplyNotifyVO> queryAllByLevelFour(WsApplyNotifyVO wsApplyNotifyVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<WsApplyNotify> wsApplyNotifys = wsApplyNotifyDao.queryAllByLevelFourByPage(wsApplyNotifyVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ wsApplyNotifys.size());
		List<WsApplyNotifyVO> list = null;
		try {
			pageSet(wsApplyNotifys, wsApplyNotifyVo);
			list = (List<WsApplyNotifyVO>) beansCopy(wsApplyNotifys, WsApplyNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

    /**
	 * 五级数据权限  
	 * @param wsApplyNotify
	 * @return 
	 */
	@SuppressWarnings("unchecked")
	public List<WsApplyNotifyVO> queryAllByLevelFive(WsApplyNotifyVO wsApplyNotifyVo) {
		logger.debug("【预留，便于后续自定义 】信息的参数信息为:");
		List<WsApplyNotify> wsApplyNotifys = wsApplyNotifyDao.queryAllByLevelFiveByPage(wsApplyNotifyVo);
		logger.debug("【预留，便于后续自定义 】信息的结果集数量为:"+ wsApplyNotifys.size());
		List<WsApplyNotifyVO> list = null;
		try {
			pageSet(wsApplyNotifys, wsApplyNotifyVo);
			list = (List<WsApplyNotifyVO>) beansCopy(wsApplyNotifys, WsApplyNotifyVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

	/**
	 * 根据applyNo查询详情
	 * @param
	 * @return
	 */
	public WsApplyNotifyVO queryByApplyNo(String applyNo) {

		logger.debug("当前查询参数信息为:"+ applyNo);
		try {
			WsApplyNotify queryRslWsApplyNotify = wsApplyNotifyDao.queryByApplyNo(applyNo);
			if (Objects.nonNull(queryRslWsApplyNotify)) {
				WsApplyNotifyVO outWsApplyNotifyVo = beanCopy(queryRslWsApplyNotify, new WsApplyNotifyVO());
				logger.debug("当前查询结果为:"+ outWsApplyNotifyVo.toString());
				return outWsApplyNotifyVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		return null;
	}
}
